{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'2021-12-24'"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from datetime import datetime # 导入datetime模块\n",
    "stamp = datetime(2021, 12,24) # 生成一个datetime对象\n",
    "stamp.strftime('%Y-%m-%d') # 结果显示：'2017-10-07'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [],
   "source": [
    "name=['元旦','除夕','春节','情人节','元宵节','植树节','清明节','劳动节','儿童节','端午节',\n",
    "      '建军节','七夕节','中秋节','国庆节','万圣夜','平安夜','圣诞节','跨年夜']\n",
    "\n",
    "day=['2021-01-01','2021-02-11','2021-02-12','2021-02-14','2021-02-26','2021-03-12','2021-04-04',\n",
    "    '2021-05-01','2021-06-01','2021-06-12','2021-08-01','2021-08-14','2021-09-21',\n",
    "    '2021-10-01','2021-10-31','2021-12-24','2021-12-25','2021-12-31']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [],
   "source": [
    "datalist=[]\n",
    "columns=['name','day']\n",
    "datalist.append(columns)\n",
    "for i in range(len(name)):\n",
    "    data=[name[i],day[i]]\n",
    "    datalist.append(data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [],
   "source": [
    "dataframe = pd.DataFrame(datalist,columns=columns)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [],
   "source": [
    "dataframe.to_csv('holiday.csv',encoding='utf-8', index=False, header=0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>name</th>\n",
       "      <th>day</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>name</td>\n",
       "      <td>day</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>元旦</td>\n",
       "      <td>2021-01-01</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>除夕</td>\n",
       "      <td>2021-02-11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>春节</td>\n",
       "      <td>2021-02-12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>情人节</td>\n",
       "      <td>2021-02-14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>元宵节</td>\n",
       "      <td>2021-02-26</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>植树节</td>\n",
       "      <td>2021-03-12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>清明节</td>\n",
       "      <td>2021-04-04</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>劳动节</td>\n",
       "      <td>2021-05-01</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>儿童节</td>\n",
       "      <td>2021-06-01</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>端午节</td>\n",
       "      <td>2021-06-12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>建军节</td>\n",
       "      <td>2021-08-01</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>七夕节</td>\n",
       "      <td>2021-08-14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>中秋节</td>\n",
       "      <td>2021-09-21</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>国庆节</td>\n",
       "      <td>2021-10-01</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>万圣夜</td>\n",
       "      <td>2021-10-31</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>平安夜</td>\n",
       "      <td>2021-12-24</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>圣诞节</td>\n",
       "      <td>2021-12-25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>跨年夜</td>\n",
       "      <td>2021-12-31</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    name         day\n",
       "0   name         day\n",
       "1     元旦  2021-01-01\n",
       "2     除夕  2021-02-11\n",
       "3     春节  2021-02-12\n",
       "4    情人节  2021-02-14\n",
       "5    元宵节  2021-02-26\n",
       "6    植树节  2021-03-12\n",
       "7    清明节  2021-04-04\n",
       "8    劳动节  2021-05-01\n",
       "9    儿童节  2021-06-01\n",
       "10   端午节  2021-06-12\n",
       "11   建军节  2021-08-01\n",
       "12   七夕节  2021-08-14\n",
       "13   中秋节  2021-09-21\n",
       "14   国庆节  2021-10-01\n",
       "15   万圣夜  2021-10-31\n",
       "16   平安夜  2021-12-24\n",
       "17   圣诞节  2021-12-25\n",
       "18   跨年夜  2021-12-31"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dataframe"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
